//Cache 
//PSim library for basic Cache

//main.c - main interface file
//it implements the interface functions with simulator engine

extern "C" {
#include <stdio.h>

#include <config.h>
#include <cpu.h>
#include <cpu-defs.h>
#include <hw.h>
#include <pc.h>

#include <psim.h>
#include <psim_lib.h>
//}

static SimDevice* cache_dev;
FILE* cache_dbg;

//Request CB
//Callback function to handle incoming requests to cache
void request_cb(Message* data)
{
  fprintf(cache_dbg, "Cache: Recived addr %04x\n", data->addr);
}

//device_load
//this function will be called very first by simulator engine
//its name shouldn't be changed..
void device_load(void *_dl_handler)
{
  cache_dbg = fopen("cache_log","w+");

  cache_dev = sim_register_device(CACHE, "b_cache", _dl_handler, 0);
  sim_register_in_cb(cache_dev, &request_cb);
}

} //extern "C"
